package com.buaa.controller;

import com.buaa.common.Result;
import com.buaa.dto.LocationDTO;
import com.buaa.enums.ResponseCode;
import com.buaa.service.impl.DriverAccidentDescServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/driverpersona")
public class DriverPersonaCtl {

    @Autowired
    private DriverAccidentDescServiceImpl accidentDescService;

    @GetMapping("/driver-vehicle-type")
    public Result byDriverAccidentVehicleType() {
        Map map = new HashMap();
        List<LocationDTO> location = accidentDescService.byDriverAccidentVehicleType();
        map.put("DRIVER", location);
        return Result.success(ResponseCode.ECHARTS_SUCCESS.getKey(), ResponseCode.ECHARTS_SUCCESS.getDesc(), location);
    }

    @GetMapping("/gender")
    public Result byDriverAccidentGender() {
        Map map = new HashMap();
        List<LocationDTO> location = accidentDescService.byDriverAccidentGender();
        map.put("DRIVER", location);
        return Result.success(ResponseCode.ECHARTS_SUCCESS.getKey(), ResponseCode.ECHARTS_SUCCESS.getDesc(), location);
    }
    @GetMapping("/age")
    public Result byDriverAccidentAge() {
        Map map = new HashMap();
        List<LocationDTO> location = accidentDescService.byDriverAccidentAge();
        map.put("DRIVER", location);
        return Result.success(ResponseCode.ECHARTS_SUCCESS.getKey(), ResponseCode.ECHARTS_SUCCESS.getDesc(), location);
    }

    @GetMapping("/time")
    public Result byDriverAccidentTime() {
        Map map = new HashMap();
        List<LocationDTO> location = accidentDescService.byDriverAccidentTime();
        map.put("DRIVER", location);
        return Result.success(ResponseCode.ECHARTS_SUCCESS.getKey(), ResponseCode.ECHARTS_SUCCESS.getDesc(), location);
    }
}
